package com.hscm.boss.convert.help;

import cn.hutool.core.util.StrUtil;
import com.hscm.boss.common.enums.PublicStatus;
import org.mapstruct.Named;
import org.springframework.stereotype.Component;

@Component
public class CommonFun {
    @Named("transPublicStatus")
    public String transPublicStatus(String status) {
        if (StrUtil.isBlank(status)) {
            return "";
        }

        //处理转换过程中的异常
        try {//将String字符串转为transPublicStatus枚举对象
            PublicStatus publicStatus = PublicStatus.valueOf(status);
            return publicStatus.getMsg();
        } catch (Exception e) {
            e.getStackTrace();
        }
        return "未知错误";
    }

    @Named("transAutoSett")
    public String transAutoSett(String autoSett) {
        if (StrUtil.isBlank(autoSett)) {
            return "";
        }

       if("YES".equals(autoSett)){
           return "是";
       }
       return "否";
    }
}
